﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace POVRay {
    [PRBlock("union")]
    public class Union : Object {
        //TODO: "inverse" keyword?

        public LinkedList<Object> Objects = new LinkedList<Object>();

        public Union(params Object[] objects) {
            foreach (var obj in objects) {
                Objects.AddLast(obj);
            }
        }

        [PRParam("split_union")]
        public bool? Split { get; set; }

        public override string ToString(int level) {
            //return this.POVRayString(level);

            StringBuilder sb = new StringBuilder();

            sb.Append("union { ");
            foreach (Object obj in Objects) {
                sb.Append(Scene.Indentation(level + 1) + obj.ToString(level + 1));
            }
            if (Split.HasValue) {
                sb.Append(Scene.Indentation(level + 1) + "split_union " + Split.Value.POVRayString());
            }
            sb.Append(GeneralParameters(level + 1));
            sb.Append(Scene.Indentation(level) + "}");

            return sb.ToString();
        }
    }
}
